In [1]:
function min( a )
    table.sort( a )
    return a[1]
end

function max( a )
    table.sort( a )
    return a[#a]
end

function mean( a )
    local sum = 0
    local count= 0
    for i, x in ipairs(a) do
        sum = sum + x
        count = count + 1
    end
    return (sum / count)
end

function median( a )
    table.sort( a )
    if math.fmod(#a,2) == 0 then
        -- return mean value of middle two elements
        return ( a[#a/2] + a[(#a/2)+1] ) / 2
    else
        -- return middle element
        return a[math.ceil(#a/2)]
    end
end

function stats( a )
    return string.format("min: %.4f, max: %.4f, mean: %.4f, median: %.4f", min(a), max(a), mean(a), median(a))
end

In [2]:
ok, reason = splash:go('http://scrapy.org/')

Wait until page is loaded


In [3]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:png()
    a[i] = os.clock() - x
end
stats(a)


Out[3]:
"min: 0.0523, max: 0.0794, mean: 0.0561, median: 0.0553"

In [4]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg()
    a[i] = os.clock() - x
end
stats(a)


Out[4]:
"min: 0.0324, max: 0.0559, mean: 0.0361, median: 0.0357"

In [5]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{quality=100}
    a[i] = os.clock() - x
end
stats(a)


Out[5]:
"min: 0.0397, max: 0.0544, mean: 0.0435, median: 0.0431"

In [6]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{quality=90}
    a[i] = os.clock() - x
end
stats(a)


Out[6]:
"min: 0.0346, max: 0.0437, mean: 0.0370, median: 0.0365"

In [7]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{quality=10}
    a[i] = os.clock() - x
end
stats(a)


Out[7]:
"min: 0.0294, max: 0.0383, mean: 0.0324, median: 0.0319"

In [8]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{quality=0}
    a[i] = os.clock() - x
end
stats(a)


Out[8]:
"min: 0.0289, max: 0.0514, mean: 0.0311, median: 0.0303"

In [ ]:
splash:go('https://blog.pinterest.com/en')

Wait until page is loaded


In [10]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:png{render_all=1}
    a[i] = os.clock() - x
end
stats(a)


Out[10]:
"min: 1.0965, max: 1.3320, mean: 1.1459, median: 1.1403"

In [11]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{render_all=1}
    a[i] = os.clock() - x
end
stats(a)


Out[11]:
"min: 0.3679, max: 0.6355, mean: 0.3975, median: 0.3881"

In [12]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{render_all=1, quality=90}
    a[i] = os.clock() - x
end
stats(a)


Out[12]:
"min: 0.3892, max: 0.4740, mean: 0.4114, median: 0.4070"

In [13]:
splash:go('http://www.w3.org/TR/2010/REC-xhtml-basic-20101123/')


Out[13]:
true

Wait until page is fully loaded


In [14]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:png{render_all=1}
    a[i] = os.clock() - x
end
stats(a)


Out[14]:
"min: 4.1127, max: 4.8878, mean: 4.3351, median: 4.3295"

In [15]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{render_all=1}
    a[i] = os.clock() - x
end
stats(a)


Out[15]:
"min: 2.4087, max: 2.9720, mean: 2.5341, median: 2.5137"

In [16]:
a = {}
for i=1,100 do
    local x = os.clock()
    splash:jpeg{render_all=1, quality=90}
    a[i] = os.clock() - x
end
stats(a)


Out[16]:
"min: 2.4447, max: 2.9938, mean: 2.6282, median: 2.6263"